package yhao.demo.autocode.core.project;

import java.io.File;

/**
 * @author yoara
 * <p> Created on 2019/3/26 </p>
 */
public class NewProjectUtil {
    public final static String CONF_DIR_PATH =
            System.getProperty("user.home") + File.separator + "yhao.newproject";

    public static String rootSrcPath(String root,String dir){
        return root + File.separator + "src" + File.separator + "main" + File.separator +
                dir + File.separator;
    }

    public static String packageToPath(String rootPackage){
        String[] tokens = rootPackage.split("\\.");
        StringBuilder sb = new StringBuilder();
        for(String token:tokens){
            sb.append(token).append(File.separator);
        }
        return sb.toString();
    }

    public static void resetDir(String path) {
        File rootDirFile = new File(path);
        if (rootDirFile.exists()) {
            rootDirFile.delete();
        }
        rootDirFile.mkdir();
    }

    public static String wordFirstUp(String word){
        return word.substring(0,1).toUpperCase() + word.substring(1);
    }
}
